package com.enfry.common.util.xml;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author hecongqi
 * @date：Sep 27, 2011 5:20:24 PM
 *
 */
public class XmlElement {

	private String key;
	private String val;
	
	private List<XmlElement> sons = new ArrayList<XmlElement>();
	
	
	public String getKey() {
		return key;
	}


	public void setKey(String key) {
		this.key = key;
	}


	public String getVal() {
		return val;
	}


	public void setVal(String val) {
		this.val = val;
	}


	public List<XmlElement> getSons() {
		return sons;
	}


	public void setSons(List<XmlElement> sons) {
		this.sons = sons;
	}


	public XmlElement get(String key){
		if(sons.isEmpty()){
			return null;
		}else{
			for(XmlElement e:sons){
				if(e.getKey().equals(key)){
					return e;
				}
			}
			return null;
		}
	}
	
	public List<XmlElement> getList(String key){
		if(sons.isEmpty()){
			return null;
		}else{
			List<XmlElement> ret = new ArrayList<XmlElement>();
			for(XmlElement e:sons){
				if(e.getKey().equals(key)){
					ret.add(e);
				}
			}
			return ret;
		}
	}
}